package com.woke.adapter;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.woke.data.Datas_clear;
import com.zhongcai.online.R;

import java.util.ArrayList;
import java.util.List;

public class Myclearadapter extends BaseAdapter{
	private LayoutInflater mInflater;
	private List<Datas_clear> datalist;

	public Myclearadapter(LayoutInflater minflater, ArrayList<Datas_clear> datalist) {
		this.mInflater = minflater;
		this.datalist = datalist;
	}

	class Holder {
		TextView info;
		TextView buyerpayamount;
		TextView paytime;
		TextView isclear;
	
	}

	@SuppressLint("SimpleDateFormat")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if(convertView == null){
			holder = new Holder();
			convertView = mInflater.inflate(R.layout.layout_include_line2, null);
			holder.info = (TextView) convertView.findViewById(R.id.include_clear);
			holder.buyerpayamount = (TextView) convertView.findViewById(R.id.include_clear2);
			holder.paytime = (TextView) convertView.findViewById(R.id.include_clear3);
			holder.isclear = (TextView) convertView.findViewById(R.id.include_clear4);

			convertView.setTag(holder);
		}else{
			 holder = (Holder) convertView.getTag();
		}
		Datas_clear data = datalist.get(position);
		holder.info.setText(data.getInfo());
		holder.buyerpayamount.setText(data.getBuyerpayamount());
//		 "2016 12 27 15 12 54"
		String time = data.getPaytime();
		String year = time.substring(0,4);
		String month = time.substring(4,6);
		String date = time.substring(6, 8);
		String hour = time.substring(8, 10);
		String minute = time.substring(10, 12);
		String second = time.substring(12, 14);
		String string = year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;

		holder.paytime.setText(string);
		if(data.getIsclear().equals("0")){
			holder.isclear.setText("待清算");
		}else if(data.getIsclear().equals("1")){
			holder.isclear.setText("已清");
		}
		
		return convertView;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datalist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;  
	}

}